package com.example.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.project.entity.Goods;
import com.example.project.mapper.GoodsMapper;

/**
 * 商品管理Controller
 *
 * @author changyao
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/project/goods")
public class GoodsController
{
    @Autowired
    private GoodsMapper goodsMapper;

    /**
     * 查询商品管理列表
     */
    @GetMapping("/list")
    public List<Goods> list()
    {
        QueryWrapper<Goods> queryWrapper=new QueryWrapper<>();
        return goodsMapper.selectList(queryWrapper);
    }




    /**
     * 获取商品管理详细信息
     */
    @PostMapping("/detil")
    public Goods getInfo(@RequestBody Goods goods)
    {
        return goodsMapper.selectById(goods);
    }


    /**
     * 新增商品管理
     */
    @PostMapping("/add")
    public int add(@RequestBody Goods goods)
    {
        return goodsMapper.insert(goods);
    }

    /**
     * 修改商品管理
     */
    @PostMapping("/edit")
    public int edit(@RequestBody Goods goods)
    {
        return goodsMapper.updateById(goods);
    }

    /**
     * 删除商品管理
     */
	@PostMapping("/del")
    public int remove(@RequestBody Goods goods)
    {
        return goodsMapper.deleteById(goods);
    }
}
